/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import entities.Catalogue;
import entities.LinkCatalogue;
import entities.Person;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author corneliugosa
 */
@Stateless
public class LinkCatalogueFacade extends AbstractFacade<LinkCatalogue> implements LinkCatalogueFacadeLocal {
    @PersistenceContext(unitName = "School-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public LinkCatalogueFacade() {
        super(LinkCatalogue.class);
    }

    @Override
    public List<Catalogue> findCatalogueByPersonId(Person person) {
        List<Catalogue> list = null;
        
        Query query = em.createNamedQuery("LinkCatalogue.findCatalogueByPerson");
        query.setParameter("person", person);
        list = query.getResultList();
        
        return list;
    }
    
}
